{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e150dc87",
   "metadata": {},
   "source": [
    "背景：某个电商平台需要计算用户购物车中商品的总价格，并给出打折后的结果。  \n",
    "题目描述：编写一个程序，根据购物车中每个商品的价格列表，计算总价格和打八折后的价格，并打印出来。购物车里商品价格分别为：50, 30, 25, 15, 40。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "30da3e1f",
   "metadata": {},
   "outputs": [],
   "source": [
    "prices = [50, 30, 25, 15, 40]\n",
    "total_price = sum(prices)\n",
    "discounted_price = total_price * 0.8\n",
    "\n",
    "print(\"总价格：\", total_price)\n",
    "print(\"打折后的价格：\", discounted_price)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ee684cd2",
   "metadata": {},
   "source": [
    " ---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "555b97f3",
   "metadata": {},
   "source": [
    "背景：某个学生成绩管理系统需要计算学生的平均成绩和最高分。  \n",
    "题目描述：编写一个程序，根据学生的成绩列表，计算平均成绩和最高分。学生成绩分别为：85, 92, 78, 89, 94。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cca4cbc4",
   "metadata": {},
   "outputs": [],
   "source": [
    "scores = [85, 92, 78, 89, 94]\n",
    "average_score = sum(scores) / len(scores)\n",
    "max_score = max(scores)\n",
    "\n",
    "print(\"平均成绩：\", average_score)\n",
    "print(\"最高分：\", max_score)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0655732",
   "metadata": {},
   "source": [
    " ---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2bbae1f6",
   "metadata": {},
   "source": [
    "背景：某商场正在举行打折促销活动，现需要编写一个程序来计算顾客购买商品的实际支付金额。\n",
    "题目描述：编写一个程序，输入商品的原价和折扣（以百分比表示），计算并输出顾客需要支付的金额。  \n",
    "提示：折后价 = 原价 × (1 - 折扣百分比/100）  \n",
    "示例：\n",
    "> 请输入商品的原价：300  \n",
    "请输入折扣（以百分比表示）：20  \n",
    "顾客需要支付的金额为： 240.0  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2a8ab0b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "original_price = float(input(\"请输入商品的原价：\"))\n",
    "discount = float(input(\"请输入折扣（以百分比表示）：\"))\n",
    "discounted_price = original_price * (1 - discount/100)\n",
    "print(\"顾客需要支付的金额为：\", discounted_price)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "88fd0163",
   "metadata": {},
   "source": [
    " ---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c1eda999",
   "metadata": {},
   "source": [
    "背景：为了提高公司员工的工作积极性，公司决定给每位员工根据其工作表现发放奖金。  \n",
    "题目描述：编写一个程序，输入员工的工作评分（以整数表示），根据评分计算并输出员工应获得的奖金金额。其中评分高于或等于90，奖金为500。评分高于或等于80，奖金为300。评分高于或等于70，奖金为100。低于70，奖金为0。  \n",
    "示例：\n",
    "> 请输入员工的工作评分：82  \n",
    "员工应获得的奖金金额为： 300"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "63bbaed1",
   "metadata": {},
   "outputs": [],
   "source": [
    "performance_score = int(input(\"请输入员工的工作评分：\"))\n",
    "bonus = 0\n",
    "if performance_score >= 90:\n",
    "    bonus = 500\n",
    "elif performance_score >= 80:\n",
    "    bonus = 300\n",
    "elif performance_score >= 70:\n",
    "    bonus = 100\n",
    "else:\n",
    "    bonus = 0\n",
    "print(\"员工应获得的奖金金额为：\", bonus)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e07520b2",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5df5ad0d",
   "metadata": {},
   "source": [
    "背景：某个游戏需要判断玩家是否具备升级的条件。  \n",
    "题目描述：编写一个程序，用户输入玩家等级和金币数量，以此判断玩家的等级是否达到升级的要求。如果玩家等级大于等于50级且拥有至少10000金币，可以进行升级，否则则不行。  \n",
    "示例：\n",
    "> 请输入玩家等级：35  \n",
    "请输入玩家金币数量：12005  \n",
    "不符合升级条件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b4f7dd80",
   "metadata": {},
   "outputs": [],
   "source": [
    "player_level = int(input(\"请输入玩家等级：\"))\n",
    "player_coins = int(input(\"请输入玩家金币数量：\"))\n",
    "\n",
    "if player_level >= 50 and player_coins >= 10000:\n",
    "    print(\"可以进行升级\")\n",
    "else:\n",
    "    print(\"不符合升级条件\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8f372175",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb716224",
   "metadata": {},
   "source": [
    "背景：某个系统为了提高安全性，要求用户输入的验证码必须是正确的。  \n",
    "题目描述：编写一个程序，自定义一个4位数的验证码，然后接收用户的输入，判断用户输入的验证码是否正确。如果用户输入的验证码与系统生成的验证码一致，则输出验证通过。  \n",
    "示例：  \n",
    "假如系统内储存的验证码是1234，\n",
    "> 请输入验证码：1234  \n",
    "验证通过"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d63f7595",
   "metadata": {},
   "outputs": [],
   "source": [
    "system_code = \"1234\"\n",
    "user_code = input(\"请输入验证码：\")\n",
    "\n",
    "if user_code == system_code:\n",
    "    print(\"验证通过\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "62f65f4e",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "20e29890",
   "metadata": {},
   "source": [
    "背景：某个游戏中，玩家需要通过回答问题来获得奖励。  \n",
    "题目描述：编写一个程序，根据问题字典，判断玩家回答的问题是否正确。如果玩家同时回答了所有问题且答案全部正确，则给予奖励。  \n",
    "问题字典的例子：\n",
    "```python\n",
    "questions = {\n",
    "    \"1. 2+2等于几？\": \"4\",\n",
    "    \"2. 地球是圆还是扁？\": \"圆\",\n",
    "    \"3. 西瓜是蔬菜还是水果？\": \"水果\"\n",
    "}\n",
    "```\n",
    "示例：\n",
    "> 1. 2+2等于几？4  \n",
    "2. 地球是圆还是扁？圆  \n",
    "3. 西瓜是蔬菜还是水果？水果  \n",
    "回答正确，给予奖励"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2c9c56e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "questions = {\n",
    "    \"1. 2+2等于几？\": \"4\",\n",
    "    \"2. 地球是圆还是扁？\": \"圆\",\n",
    "    \"3. 西瓜是蔬菜还是水果？\": \"水果\"\n",
    "}\n",
    "\n",
    "answered_all = True\n",
    "all_correct = True\n",
    "\n",
    "for question, answer in questions.items():\n",
    "    user_answer = input(question)\n",
    "    if user_answer != answer:\n",
    "        all_correct = False\n",
    "    if user_answer == \"\":\n",
    "        answered_all = False\n",
    "\n",
    "if answered_all and all_correct:\n",
    "    print(\"回答正确，给予奖励\")\n",
    "else:\n",
    "    print(\"回答错误或未回答完所有问题\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7c3c1c7e",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f357a3c0",
   "metadata": {},
   "source": [
    "背景：某个餐厅需要统计每天就餐人数并计算平均每桌就餐人数。  \n",
    "题目描述：编写一个程序，输入每桌就餐人数，统计总就餐人数和平均每桌就餐人数，直到输入-1结束统计。  \n",
    "示例：\n",
    "> 请输入每桌就餐人数（输入-1结束统计）：2  \n",
    "请输入每桌就餐人数（输入-1结束统计）：5  \n",
    "请输入每桌就餐人数（输入-1结束统计）：3  \n",
    "请输入每桌就餐人数（输入-1结束统计）：4  \n",
    "请输入每桌就餐人数（输入-1结束统计）：2  \n",
    "请输入每桌就餐人数（输入-1结束统计）：4  \n",
    "请输入每桌就餐人数（输入-1结束统计）：-1  \n",
    "总就餐人数： 20  \n",
    "平均每桌就餐人数： 3.3333333333333335"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9fcc6203",
   "metadata": {},
   "outputs": [],
   "source": [
    "total_customers = 0\n",
    "table_count = 0\n",
    "\n",
    "while True:\n",
    "    customer_count = int(input(\"请输入每桌就餐人数（输入-1结束统计）：\"))\n",
    "    if customer_count == -1:\n",
    "        break\n",
    "    total_customers += customer_count\n",
    "    table_count += 1\n",
    "\n",
    "average_customers = total_customers / table_count if table_count > 0 else 0\n",
    "\n",
    "print(\"总就餐人数：\", total_customers)\n",
    "print(\"平均每桌就餐人数：\", average_customers)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "99dc4289",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e122c3f2",
   "metadata": {},
   "source": [
    "背景：某个音乐播放器需要循环播放指定的歌曲列表。  \n",
    "题目描述：编写一个程序，当用户输入“下一首”时，按照顺序循环播放歌曲列表，直到用户输入“停止”，表明要求停止播放。  \n",
    "歌曲列表的例子：\n",
    "```python\n",
    "songs = [\"歌曲1\", \"歌曲2\", \"歌曲3\"]\n",
    "```\n",
    "示例：\n",
    "> 正在播放歌曲： 歌曲1  \n",
    "输入'下一首'播放下一首歌曲，输入'停止'停止播放：下一首  \n",
    "正在播放歌曲： 歌曲2  \n",
    "输入'下一首'播放下一首歌曲，输入'停止'停止播放：下一首  \n",
    "正在播放歌曲： 歌曲3  \n",
    "输入'下一首'播放下一首歌曲，输入'停止'停止播放：下一首  \n",
    "正在播放歌曲： 歌曲1  \n",
    "输入'下一首'播放下一首歌曲，输入'停止'停止播放：下一首  \n",
    "正在播放歌曲： 歌曲2  \n",
    "输入'下一首'播放下一首歌曲，输入'停止'停止播放：-  \n",
    "正在播放歌曲： 歌曲2  \n",
    "输入'下一首'播放下一首歌曲，输入'停止'停止播放：-  \n",
    "正在播放歌曲： 歌曲2  \n",
    "输入'下一首'播放下一首歌曲，输入'停止'停止播放：下一首  \n",
    "正在播放歌曲： 歌曲3  \n",
    "输入'下一首'播放下一首歌曲，输入'停止'停止播放：停止"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3d894b91",
   "metadata": {},
   "outputs": [],
   "source": [
    "songs = [\"歌曲1\", \"歌曲2\", \"歌曲3\"]\n",
    "playing = True\n",
    "current_song_index = 0\n",
    "\n",
    "while playing:\n",
    "    print(\"正在播放歌曲：\", songs[current_song_index])\n",
    "    user_input = input(\"输入'下一首'播放下一首歌曲，输入'停止'停止播放：\")\n",
    "    if user_input == \"下一首\":\n",
    "        current_song_index = (current_song_index + 1) % len(songs)\n",
    "    elif user_input == \"停止\":\n",
    "        playing = False"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1b6c24bf",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5397690f",
   "metadata": {},
   "source": [
    "背景：某个学校需要统计每个班级的学生人数并计算总学生人数。  \n",
    "题目描述：编写一个程序，先询问所有班级的数量，然后让用户输入各个班级的学生人数，从而统计所有班级的总学生人数。  \n",
    "示例：\n",
    "> 请输入班级数量：5  \n",
    "请输入第 1 个班级的学生人数：39  \n",
    "请输入第 2 个班级的学生人数：42  \n",
    "请输入第 3 个班级的学生人数：41  \n",
    "请输入第 4 个班级的学生人数：40  \n",
    "请输入第 5 个班级的学生人数：42  \n",
    "总学生人数： 204"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "29537027",
   "metadata": {},
   "outputs": [],
   "source": [
    "total_students = 0\n",
    "class_count = int(input(\"请输入班级数量：\"))\n",
    "\n",
    "for i in range(1, class_count + 1):\n",
    "    student_count = int(input(\"请输入第 {} 个班级的学生人数：\".format(i)))\n",
    "    total_students += student_count\n",
    "\n",
    "print(\"总学生人数：\", total_students)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8c7cba67",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "173b8945",
   "metadata": {},
   "source": [
    "背景：某个学生管理系统需要将学生信息保存到文件中。  \n",
    "题目描述：编写一个程序，用户可以在输入一个学生的姓名和年龄，将其保存到一个文本文件中。\n",
    "示例：\n",
    "> 请输入学生姓名：粒粒  \n",
    "请输入学生年龄：5  \n",
    "学生信息已保存到文件。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5e1e5f5a",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = input(\"请输入学生姓名：\")\n",
    "age = input(\"请输入学生年龄：\")\n",
    "\n",
    "with open(\"students.txt\", \"w\") as file:\n",
    "    file.write(f\"姓名：{name}\\n\")\n",
    "    file.write(f\"年龄：{age}\\n\")\n",
    "\n",
    "print(\"学生信息已保存到文件。\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ba8ee505",
   "metadata": {},
   "source": [
    "背景：某个日志系统需要将用户的操作记录保存到日志文件中。  \n",
    "题目描述：编写一个程序，输入用户的操作记录，将其保存到一个日志文件中（每条记录占一行）。  \n",
    "示例：\n",
    "> 请输入操作记录：打开文件  \n",
    "操作记录已保存到日志文件。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a0a6301a",
   "metadata": {},
   "outputs": [],
   "source": [
    "log_entry = input(\"请输入操作记录：\")\n",
    "\n",
    "with open(\"log.txt\", \"a\") as file:\n",
    "    file.write(log_entry + \"\\n\")\n",
    "\n",
    "print(\"操作记录已保存到日志文件。\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "06680ed9",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "965043d7",
   "metadata": {},
   "source": [
    "背景：某个日程管理系统需要读取用户的日程安排。  \n",
    "题目描述：编写一个程序，读取名为\"schedules.txt\"的文本文件，逐行打印出其中的日程安排。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4cc1e531",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"schedules.txt\", \"r\") as file:\n",
    "    schedules = file.readlines()\n",
    "\n",
    "for schedule in schedules:\n",
    "    print(schedule)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a28b7e4a",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3b37186",
   "metadata": {},
   "source": [
    "背景：某个计算器程序需要处理除零错误。  \n",
    "题目描述：编写一个程序，输入两个数进行除法运算，如果除数为零，则捕获异常并输出错误提示。\n",
    "示例一：\n",
    "> 请输入被除数：5  \n",
    "请输入除数：8  \n",
    "结果： 0.625\n",
    "\n",
    "示例二：\n",
    "> 请输入被除数：23  \n",
    "请输入除数：0  \n",
    "除数不能为零"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "90d49339",
   "metadata": {},
   "outputs": [],
   "source": [
    "try:\n",
    "    dividend = int(input(\"请输入被除数：\"))\n",
    "    divisor = int(input(\"请输入除数：\"))\n",
    "    result = dividend / divisor\n",
    "    print(\"结果：\", result)\n",
    "except ZeroDivisionError:\n",
    "    print(\"除数不能为零\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ec1bc59",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "24c7ffea",
   "metadata": {},
   "source": [
    "背景：某个文件读取程序需要处理文件不存在的情况。  \n",
    "题目描述：编写一个程序，读取名为\"data.txt\"的文件内容，如果文件不存在，则捕获异常并输出错误提示：“文件不存在，请检查文件名”。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d62053c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "try:\n",
    "    with open(\"data.txt\", \"r\") as file:\n",
    "        content = file.read()\n",
    "    print(content)\n",
    "except FileNotFoundError:\n",
    "    print(\"文件不存在，请检查文件名\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95fe8117",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "51e32c06",
   "metadata": {},
   "source": [
    "背景：某个图书管理系统需要管理图书馆中的书籍信息。  \n",
    "题目描述：创建一个Book类，包含图书的属性（书名 `title`、作者 `author`、出版年份 `year`）和方法（展示图书信息 `display_info`，用于打印所有属性的信息）。然后再创建一个Book类的实例，并调用`display_info`方法，来打印该书籍的信息。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "43e3b49a",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Book:\n",
    "    def __init__(self, title, author, year):\n",
    "        self.title = title\n",
    "        self.author = author\n",
    "        self.year = year\n",
    "    \n",
    "    def display_info(self):\n",
    "        print(f\"书名：{self.title}\")\n",
    "        print(f\"作者：{self.author}\")\n",
    "        print(f\"出版年份：{self.year}\")\n",
    "\n",
    "book1 = Book(\"Python编程入门\", \"张三\", 2021)\n",
    "book1.display_info()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "910431ee",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f49743c",
   "metadata": {},
   "source": [
    "背景：某个几何图形计算程序需要计算圆的相关信息。  \n",
    "题目描述：设计一个Circle类，包含圆的属性（半径 `radius`）和方法（计算周长和面积 `calculate_circumference` 和 `calculate_area`）。然后再创建一个Circle类的实例，并调用方法分别计算周长和面积，并进行打印。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "73422b30",
   "metadata": {},
   "outputs": [],
   "source": [
    "import math\n",
    "\n",
    "class Circle:\n",
    "    def __init__(self, radius):\n",
    "        self.radius = radius\n",
    "    \n",
    "    def calculate_circumference(self):\n",
    "        return 2 * math.pi * self.radius\n",
    "    \n",
    "    def calculate_area(self):\n",
    "        return math.pi * self.radius ** 2\n",
    "\n",
    "circle1 = Circle(5)\n",
    "circumference = circle1.calculate_circumference()\n",
    "area = circle1.calculate_area()\n",
    "print(\"圆的周长：\", circumference)\n",
    "print(\"圆的面积：\", area)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "31c74a36",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f7f27165",
   "metadata": {},
   "source": [
    "背景：某个矩形计算程序需要计算矩形的相关信息。  \n",
    "题目描述：设计一个Rectangle类，包含矩形的属性（长 `length` 和宽 `width`）和方法（计算周长和面积 `calculate_perimeter` 和 `calculate_area`）。设计一个Rectangle类，并调用方法分别计算周长和面积，并进行打印。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c49ca28e",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Rectangle:\n",
    "    def __init__(self, length, width):\n",
    "        self.length = length\n",
    "        self.width = width\n",
    "    \n",
    "    def calculate_perimeter(self):\n",
    "        return 2 * (self.length + self.width)\n",
    "    \n",
    "    def calculate_area(self):\n",
    "        return self.length * self.width\n",
    "\n",
    "rectangle1 = Rectangle(4, 6)\n",
    "perimeter = rectangle1.calculate_perimeter()\n",
    "area = rectangle1.calculate_area()\n",
    "print(\"矩形的周长：\", perimeter)\n",
    "print(\"矩形的面积：\", area)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2505417f",
   "metadata": {},
   "source": [
    " ----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9bc6a8d0",
   "metadata": {},
   "source": [
    "背景：某个公司的员工分为正式员工和临时员工。  \n",
    "题目描述：设计一个Employee类作为父类，包含员工的基本属性（姓名 `name`、工号 `emp_id`）和方法（展示员工信息，即姓名和工号 `display_info`）。然后设计一个RegularEmployee类和一个TemporaryEmployee类，分别继承自Employee类，但它们各自有额外的属性和方法。具体来说，RegularEmployee的员工有部门属性 `department`，TemporaryEmployee的员工有项目属性 `project`，并且它们各自的`display_info`方法也会把独有的部门或项目信息打印出来。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "256856a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Employee:\n",
    "    def __init__(self, name, emp_id):\n",
    "        self.name = name\n",
    "        self.emp_id = emp_id\n",
    "    \n",
    "    def display_info(self):\n",
    "        print(f\"姓名：{self.name}\")\n",
    "        print(f\"工号：{self.emp_id}\")\n",
    "\n",
    "class RegularEmployee(Employee):\n",
    "    def __init__(self, name, emp_id, department):\n",
    "        super().__init__(name, emp_id)\n",
    "        self.department = department\n",
    "    \n",
    "    def display_info(self):\n",
    "        super().display_info()\n",
    "        print(f\"部门：{self.department}\")\n",
    "\n",
    "class TemporaryEmployee(Employee):\n",
    "    def __init__(self, name, emp_id, project):\n",
    "        super().__init__(name, emp_id)\n",
    "        self.project = project\n",
    "    \n",
    "    def display_info(self):\n",
    "        super().display_info()\n",
    "        print(f\"项目：{self.project}\")\n",
    "\n",
    "regular_employee = RegularEmployee(\"张三\", \"E001\", \"销售部\")\n",
    "regular_employee.display_info()\n",
    "\n",
    "temporary_employee = TemporaryEmployee(\"李四\", \"E002\", \"市场调研\")\n",
    "temporary_employee.display_info()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
